package com.ruoyi.web.controller.kujiale;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.dto.design.DesignDTO;
import com.ruoyi.system.dto.design.DesignQueryDTO;
import com.ruoyi.system.dto.design.UpdateDesignDto;
import com.ruoyi.system.service.DesignService;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/design")
public class DesignController {


    @Resource
    private DesignService designService;

    @PostMapping("/add")
    @ApiOperation("新建设计")
    public AjaxResult createDesign(@Validated @RequestBody DesignDTO designDTO) {
        return AjaxResult.success(designService.createDesign(designDTO));
    }


    @PutMapping("/{id}")
    @ApiOperation("更新设计")
    public AjaxResult updateProject(@PathVariable Long id, @Validated @RequestBody UpdateDesignDto updateDesignDto) {
        return AjaxResult.success(designService.updateDesign(id, updateDesignDto));
    }


    @DeleteMapping("/{id}")
    @ApiOperation("删除设计")
    public AjaxResult deleteDesign(@PathVariable Long id) {
        return AjaxResult.success(designService.deleteDesign(id));
    }

    @GetMapping("/page_list")
    @ApiOperation("查询列表")
    public AjaxResult getPageList(DesignQueryDTO query) {
        return AjaxResult.success(designService.getPageList(query));
    }

    @GetMapping("/{id}")
    @ApiOperation("根据ID查询设计")
    public AjaxResult getDesignById(@PathVariable Long id) {
        return AjaxResult.success(designService.getDesignById(id));
    }

    @GetMapping("/details/{h5UserId}")
    @ApiOperation("非常详情")
    public AjaxResult getDesignDetailsById(@PathVariable Long h5UserId) {
        return AjaxResult.success(designService.getDesignDetailsByUserId(h5UserId));
    }
}
